<?php
require_once('lib/db_connection.php');
$query_veh = "SELECT * FROM dts_veh_tbl WHERE company_id='".$_SESSION['company_id']."'";
$result_veh = mysql_query($query_veh) or die("SELECT VEHICLES ".mysql_error());
?>
<html>
<head>
<script type='text/javascript' src='js/select_helper.js'></script>
<!--<link rel="stylesheet" type="text/css" href="css/grid.css" />-->
</head>

<body onLoad='checkIt()' style="background-color:black">
<p style='color:white;font-size:12px;' id='tot_loaded'></p>
<hr />
 <?php
 $str_ids = "";
 $tot_loaded = 0;
 while($row_veh = mysql_fetch_array($result_veh))
 {
 $query_queue = "SELECT * FROM queue_tbl WHERE plate_id='".$row_veh['vehicle_id']."' ORDER BY autoid DESC LIMIT 0,1";
 $result_count = mysql_query($query_queue) or die("CHECK QUEUE ".mysql_error());
 $count = mysql_num_rows($result_count);
 if($count!=0)
 {
 $result_queue = mysql_query($query_queue) or die("SELECT QUEUE ".mysql_error());
 $row_queue = mysql_fetch_array($result_queue );
 
 $mktime_diff = 0;
 if($row_queue['loaded_timestamp']!='')
 {
 $loaded_date = substr($row_queue['loaded_timestamp'],0,10);
 $arr_date = explode('-',$loaded_date);
 $loaded_time = substr($row_queue['loaded_timestamp'],11,5);
 $arr_time = explode(':',$loaded_time);
 
 $loaded_mktime = mktime($arr_time[0],$arr_time[1],0,$arr_date[1],$arr_date[2],$arr_date[0]);
 $present_mktime = mktime(date('H'),date('i'),date('s'),date('m'),date('d'),date('Y'));
 $mktime_diff = $present_mktime - $loaded_mktime;
 }
 
 if($row_queue['status']=='loaded' && $row_queue['intransit_timestamp']=='' && $mktime_diff>3600)
 {
 $tot_loaded++;
?>
  <span style='font-size:12px;color:white;'><?php echo $row_veh["veh_num"]?><span>
  <br />
<?php
 }
 }
 }
 echo "<script type='text/javascript'>
 document.getElementById('tot_loaded').innerHTML = 'TOTAL: '+'".$tot_loaded."';
 </script>";
?>
</table>
</body>
</html>